//
//  SRTaskBriefView.m
//  SportRing
//
//  Created by mykoma on 14-4-5.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRTaskBriefView.h"
#import <RTLabel.h>
#import "LGProgressView.h"

@interface SRTaskBriefView ()
{
    UIView * _taskIdxIV;
    UILabel * _taskIdxLabel;
    RTLabel * _stepInfoLabel;
    RTLabel * _percentLabel;
    LGProgressView * _progressView;
    
    UIImageView * _rightArrowIcon;
}

@end

@implementation SRTaskBriefView

-(void)loadData:(SRTaskBriefViewData *)data
{
    [_progressView setProgress:data.percent];
    
    _taskIdxLabel.text = [@(data.taskIdx) stringValue];
    
    _taskIdxIV.backgroundColor = [UIColor red:22 green:187 blue:92 alpha:1];
    
    NSString * stepInfoString = [NSString stringWithFormat:@"<font size=35 color='#16bb5c'>%d</font><font size=15 color='#16bb5c'>步</font>", data.stepCount];
    [_stepInfoLabel setText:stepInfoString];
    
    NSString * percentString = [NSString stringWithFormat:@"<font size=20 color='#16bb5c'>%d</font><font size=15 color='#16bb5c'>%%</font>", data.percent];
    [_percentLabel setText:percentString];
}

#pragma mark - SRBaseViewProtocol

-(void)setupViews
{
    _taskIdxIV = [UIView new];
    [self addSubview:_taskIdxIV];
    
    _taskIdxLabel = [UILabel new];
    _taskIdxLabel.textColor = [UIColor whiteColor];
    _taskIdxLabel.textAlignment = NSTextAlignmentCenter;
    [_taskIdxIV addSubview:_taskIdxLabel];
    
    _stepInfoLabel = [RTLabel new];
    [self addSubview:_stepInfoLabel];
    
    _percentLabel = [RTLabel new];
    [self addSubview:_percentLabel];
    
    _progressView = [LGProgressView new];
    [self addSubview:_progressView];
    
    _rightArrowIcon = [UIImageView new];
    _rightArrowIcon.image = [UIImage imageNamed:@"select_right"];
    [self addSubview:_rightArrowIcon];
    
    // TODO for tableview cell.
    [self layoutPortrait];
}

-(void)layoutPortrait
{
    _taskIdxIV.frame = CGRectMake(10, 20, 40, 40);
    _taskIdxIV.layer.cornerRadius = 20.0f;
    
    _taskIdxLabel.frame = CGRectMake(0, 10, 40, 20);
    
    _stepInfoLabel.frame = CGRectMake(60, 15, 160, 44);
    
    _percentLabel.frame = CGRectMake(255, 40, 50, 26);
    
    _progressView.frame = CGRectMake(60, 65, 250, 3);
    
    _rightArrowIcon.frame = CGRectMake(270, 10, 36, 36);
}

@end

@implementation SRTaskBriefViewData

@end